//
//  ViewController.m
//  baseProject
//
//  Created by glavesoft on 15/2/28.
//  Copyright (c) 2015年 glavesoft. All rights reserved.
//

#import "ViewController.h"
#import "textView.h"
@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.title = @"测试WebService和BLOCK";
    textView *_view1 = [[textView alloc] initWithFrame:CGRectMake(0, 0, self.view.width, 100)];
    _view1.backgroundColor = [UIColor blackColor];
//    _view1.splashView = @"ddd";
    _view1.delegate= self;
    self.textView1 = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, self.view.width, self.view.height - 44 - 10)];
    self.textView1.text = @"dddd";
    [self.view addSubview:_view1];
//    [self.view addSubview:self.textView1];
    helper=[[ServiceHelper alloc] initWithDelegate:self];
//    [self getList];
    
}
#pragma mark MyDelegate
-(void)buyIphone:(NSString *)iphoneType money:(NSString *)money
{
    [self getList];
}

-(void)getList
{
    [Glob showHUD:@"loading"];//显示动画
    NSLog(@"=======异步请求开始======\n");
    NSMutableArray *arr=[NSMutableArray array];
    [arr addObject:[NSDictionary dictionaryWithObjectsAndKeys:@"20",@"pagesize", nil]];
    [arr addObject:[NSDictionary dictionaryWithObjectsAndKeys:@"1",@"pageindex", nil]];
    [arr addObject:[NSDictionary dictionaryWithObjectsAndKeys:@"0AB0F29B-B1AB-6A0A-6FFF-88618606D1A0",@"code", nil]];
    NSString *soapMsg=[SoapHelper arrayToDefaultSoapMessage:arr methodName:@"GetSpecialActivitiesList"];
    //    [helper asynServiceMethod:@"GetSpecialActivitiesList" soapMessage:soapMsg];
    
    __weak ViewController*_weakSelf = self;
    [helper asynServiceRequestUrl:defaultWebServiceUrl serviceNameSpace:defaultWebServiceNameSpace serviceMethodName:@"GetSpecialActivitiesList" soapMessage:soapMsg successBlock:^(id obj){
        [Glob removeHUD];
        NSDictionary *dic = [obj objectFromJSONStringWithParseOptions:JKParseOptionLooseUnicode];
        NSString *str1 = [[[dic objectForKey:@"content"] objectAtIndex:0] objectForKey:@"title"];
        NSLog(@"%@",str1);
        [_weakSelf settext];
        self.textView1.text = obj;
        
        
        
    } failBlock:^(id obj){
        [Glob removeHUD];
        NSLog(@"%@",obj);
    }];
}

-(void)settext{
    self.textView1.text = @"hahaha";
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
